/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2023. All rights reserved.
 * Description: add memstat for vmalloc and buddy for modules
 * Author: Lv Ying
 * Create: 2020-04-10
 */

#ifndef _LINUX_MEMSTAT_H
#define _LINUX_MEMSTAT_H

#ifdef CONFIG_EULEROS_MEMSTAT
extern struct list_head *mem_modules;
typedef int (*memory_count_func)(unsigned long addr, int size);
extern int memstat_enable;
extern void memstat_page_caller(unsigned long pfn, unsigned int size);
extern void memstat_page_free(struct page *page, unsigned int order);
extern unsigned long memstat_get_max_count_num(void);
#define MEMSTAT_PAGE_CALLER(page, size)					\
	do {								\
		if (unlikely(memstat_enable))				\
			memstat_page_caller(page_to_pfn(page), size);	\
	} while (0)
#define MEMSTAT_PAGE_FREE(page, size)					\
	do {								\
		if (unlikely(memstat_enable))				\
			memstat_page_free(page, size);			\
	} while (0)
#else
#define MEMSTAT_PAGE_CALLER(page, size)
#define MEMSTAT_PAGE_FREE(page, size)
#endif

#endif /* _LINUX_MEMSTAT_H */
